{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<style type="text/css">
		.mask .mask-content{height: 17vh}
		.img-1{height: 80px !important;width: 80px!important;}
		.gray{background: rgba(235,235,235,0.5);}
	</style>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd><form method="get"><input type="text" class="input" placeholder="请输入您需要搜索的内容！" name="search"><input type="submit" value="搜索" class="button" /></form></dd>
			</dl>
		</div>
		<div class="content">
			<div class="release">
				<dl>
					<dt><i class="iconfont">&#xe649;</i> <b>{{.title}}说明</b><br>
					</dt>
					<dd><a href="/admin/active/sales_add"><button type="button" class="button">添加促销</button></a></dd>
				</dl>
			</div>

			<table class="table">
				<thead><th width="15%">产品图片</th><th width="25%">促销信息</th><th width="20%">参加信息</th><th width="20%"> 时间</th><th width="20%">操作</th></thead>
				{{range .info}}
				<tr id="{{.id}}">
					<td class="center"><a href="/admin/product/content?id={{.pid}}"><img src="{{.pathname}}" class="img"></a></td>
					<td>
						产品名称：<a href="/admin/product/content?id={{.pid}}">{{.pname}}</a><br>
						标题：<mark>{{.title}}</mark><br>
						团购价格：<b>&yen;{{.price}}</b><br>
						<!-- 开团数量：{{.num}}<br> -->
						排序：{{.sort}}<br>
					</td>
					<td>
						参加人数：{{.jnum}}<br>
						购买总数：{{.jgnum}}<br>
						<!-- <a href="/admin/active/gbuy_join?id={{.id}}" class="tz">参团列表</a> -->
					</td>
					<td>
						添加时间：{{.addtime}}<br>
						开团时间：{{.starttime}}<br>
						结束时间：{{.endtime}}<br>
					</td>
					<td class="operation">
						<a href="/admin/active/sales_edit?id={{.id}}">编辑</a><br>
						<a class="del" data-id="{{.id}}">删除</a><br>
						{{if eq .end "0"}}
						<!-- <a class="push" data-id="{{.id}}">团购推送</a><br> -->
						<!-- <a class="ret" data-id="{{.id}}">团购退款</a><br> -->
						<a class="end" data-id="{{.id}}">进行中</a><br>
						{{else}}
						<a class="end" data-id="{{.id}}">已结束</a><br>
						{{end}}
					</td>
				</tr>
				{{end}}
				{{if ne .paginator.totalpages 1}}
					<tr>
						<td  colspan="5">
							<div class="paging">
								{{if ne .paginator.currpage 1}}
								<a href="{{$.url}}page={{.paginator.firstpage}}">首页</a>
								<a href="{{$.url}}page={{.paginator.prevpage}}">&lt;&lt;</a>
								{{else}}
								<a class="disable">首页</a>
								<a class="disable">&lt;&lt;</a>
								{{end}}
								{{range $index,$page := .paginator.pages}}
								{{if eq $.paginator.currpage $page}} 
								<a class="no">{{$page}}</a>
								{{else}}
								<a href="{{$.url}}page={{$page}}">{{$page}}</a>
								{{end}}
								{{end}}
								{{if eq .paginator.currpage .paginator.totalpages}}
								<a class="disable">&gt;&gt;</a>
								<a class="disable">尾页</a>
								{{else}}
								<a href="{{$.url}}page={{.paginator.nextpage}}">&gt;&gt;</a>
								<a href="{{$.url}}page={{.paginator.totalpages}}">尾页</a>
								{{end}}
							</div>
						</td>
					</tr>
				{{end}}
			</table>


		</div>

		<div class="mask">
		<div class="mask-content">
			<form id="parameter">
				<table class="table1">
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td class="genre" colspan="2">原价</td>
						<td colspan="6">
							{{range .vip}}
							<label><input type="checkbox" name="vid" value="{{.id}}">{{.name}}</label>
							{{end}}
						</td>
					</tr>
				</table>
				<input type="hidden" name="id">
			</form>
			<p id="tip"></p>
			<div class="mask-form">
				<dl>
					<dt>
						<button id="qr">保存</button>
						<button id="cancle">取消</button>
					</dt>
					<dd>
					</dd>
				</dl>
			</div>
		</div>
	</div>
	</article>
</section>

<footer><!-- 系统监控内容 --></footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
	$('.push').click(function(){
	 	var id=$(this).attr('data-id');
	 	$('input[name="id"]').val(id)
	 	$('.mask').css('display','block')
		// wxc.xcConfirm("请输入团购推送文案","input",{onOk:function(res){
		// 	$.ajax({
		// 		url:'/admin/active/gbuy_push',
		// 		data:{id:id,content:res},
		// 		type:'get',
		// 		success:function(res) {
		// 			if(res==1){
		// 				showMessage('推送成功');
		// 				history.go(0)
		// 			}else{
		// 				wxc.xcConfirm("操作失败,请重试","error");
		// 			}
		// 		}
		// 	})	
		// }});
	})
	$('#cancle').click(function(){
		$('#money').val('')
		$('input[name="id"]').val('')
		$('input[name="price"]').val('')
		$('.mask').css('display','none')
	})
	$('#qr').click(function(){
		wxc.xcConfirm("请输入团购推送文案","input",{onOk:function(res){
			var form=$('#parameter').serialize()
			form+=`&content=`+res
			$.ajax({
				url:'/admin/active/gbuy_push',
				data:form,
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('推送成功');
						history.go(0)
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
	$('.end').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要更改状态吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/active/sales_end',
				data:{id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						history.go(0)
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
	$('.ret').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要团购退款吗吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/active/gbuy_ret',
				data:{id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						history.go(0)
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
    $('.del').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要删除这条数据吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/del',
				data:{table:'mt_active_sales',id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('删除成功');
						$('#'+id).css('display','none');
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})

</script>
</body>
</html>
